#ifndef COAPSERVERTASK_H
#define COAPSERVERTASK_H

#include <string>
#include <doors/ptb.h>
#include <doors/udp.h>
#include <doors/ptask.h>
#include <doors/inetaddr.h>
#include <doors/timer.h>
#include "coapserversap.h"
#include "coapserversm.h"
#include "coappdu.h"
#include "options.h"

class CoapServerTaskSM;

class CoapServerTask : public PTask {

  public:

   UdpSAP::User down;     
   CoapServerSAP::Provider up;
   CoapPeer peer;          

   CoapServerTask(std::string name, Scheduler* s, 
		  CoapServerTaskSM* sm, InetAddr clientaddr);
   virtual ~CoapServerTask();

   // Idle state
   bool idle_Default(Message* msg) { return false; }
   bool idle_CON(Message* msg);
   bool idle_NON(Message* msg);

   // Getters
   Options& getOptions(void); 
   Uint16 getMsgID(void) const;
   void serveRequest(Uint8 requestCode, Frame& data);
   bool getFile(std::string uripath, Frame& data);

   // Setters
   void setMsgID(Uint16 msgID);
   bool putFile(std::string uripath, Frame& data);
   bool delFile(std::string uripath);
  
  private:
   void sendACK(Uint8 responseCode, Frame& data);
/*   void receiveDATA(Message* msg); */

  // Class variables
  Uint16 msgID_;
  Options options_;
  InetAddr clientaddr_;
};

#endif

